home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 050a / tse_mac1.zip / SAVER.ZIP / CMDLINE.ASM next >
Assembly Source File  |  1993-04-20  |  2KB  |  49 lines

  1. _TEXT  segment
  2.        assume  cs:_TEXT
  3.  
  4. ; integer proc getcmdtext(var string cmdline)
  5. ;
  6. ; stack looks like following:
  7. ;
  8. ; pointer to 'cmd' string   :   far (dword)
  9. ; max_len of 'cmd' string   :   word
  10. ; return address            :   far (dword)
  11. ;
  12. ; the current length of strings is passed in the first word
  13. ; of the string itself
  14.  
  15. CMDTEXT             equ     bp + 6
  16. MAX_LEN             equ     bp + 4
  17.  
  18. GETCMDTEXT     proc    far     ; procedure must be FAR routine
  19.  
  20.         mov     bp, sp                  ;set up standard stack frame
  21.  
  22.         mov     ah,62h
  23.         int     21h                     ;get pointer to psp into bx
  24.  
  25.         push    ss                      ;point ds to stack for this function
  26.         pop     ds
  27.  
  28.         les     di, dword ptr [CMDTEXT] ;load es:di with pointer to CMDTEXT
  29.  
  30.         mov     ds,bx                   ;ds points to psp
  31.         mov     si,80h                  ;point to command tail length byte
  32.         lodsb                           ;get the length
  33.         stosb                           ;write length into return string
  34.         inc     di                      ;skip reserved byte
  35.         mov     cl,al                   ;into cx for repeat
  36.         mov     ch,0                    ;
  37.         rep     movsb                   ;write string
  38.  
  39.         xor     ax,ax                   ;always return a zero
  40.         cwd
  41.         retf
  42.  
  43. stuff:  db      'this is a test string                     '
  44.  
  45. getcmdtext endp
  46.  
  47. _TEXT   ends
  48.         end
  49.